[main]
filesize=18927613
sha512=3b29aba3d90525d6cc4fcc2e0b99ac9f65a5cda488937346c2c742647b8b2f3b93644bfef801eda358945f9beef6a2cd108bb43071d0b13dce384f282921a7ca
tardir=gcc-4.2.4

[deps]

[mirrors]
http://ftp.gnu.org/gnu/gcc/gcc-4.2.4/gcc-core-4.2.4.tar.bz2

[build]
VERSION=4.2.4

patch -p1 < "$K"/gcc-424-libgcc-visibility.patch

sed -i 's@\./fixinc\.sh@-c true@' gcc/Makefile.in
sed -i 's@/lib/ld-linux.so.[12]@/lib/ld-musl-i386.so.1@' gcc/config/i386/linux.h
sed -i 's@/lib/ld-linux.so.[12]@/lib/ld-musl-i386.so.1@' gcc/config/i386/linux64.h
sed -i 's@/lib64/ld-linux-x86-64.so.2@/lib/ld-musl-x86_64.so.1@' gcc/config/i386/linux64.h
sed -i 's@/lib/ld.so.1@/lib/ld-musl-mips.so.1@' gcc/config/mips/linux.h
sed -i 's@/lib/ld.so.1@/lib/ld-musl-mips.so.1@' gcc/config/mips/linux64.h
sed -i 's@/lib64/ld.so.1@/lib/ld-musl-mips.so.1@' gcc/config/mips/linux64.h
sed -i 's@/lib32/ld.so.1@/lib/ld-musl-mips.so.1@' gcc/config/mips/linux64.h
sed -i 's@/lib/ld.so.1@/lib/ld-musl-powerpc.so.1@g' gcc/config/rs6000/sysv4.h
sed -i 's@/lib/ld.so.1@/lib/ld-musl-powerpc.so.1@g' gcc/config/rs6000/linux64.h
sed -i 's@/lib64/ld64.so.1@/lib/ld-musl-powerpc64.so.1@g' gcc/config/rs6000/linux64.h
sed -i 's@/lib/ld-linux.so.3@/lib/ld-musl-arm.so.1@' gcc/config/arm/linux-eabi.h
sed -i 's@/lib/ld-linux.so.2@/lib/ld-musl-arm.so.1@' gcc/config/arm/linux-elf.h

$K/bin/libibertyfix libiberty

armflags=
[ -z "$ARM_FLOAT_MODE" ] && ARM_FLOAT_MODE=softfp
[ -z "$ARM_FPU" ] && ARM_FPU=vfp
[ "$A" = "arm" ] && armflags="--with-float=$ARM_FLOAT_MODE --with-fpu=$ARM_FPU --target=arm-linux-gnueabi --host=arm-linux-gnueabi --build=arm-linux-gnueabi"

echo ac_cv_func_strsignal=yes > config.site
./configure --prefix="$butch_prefix" \
--mandir="$butch_prefix"/share/man \
--infodir="$butch_prefix"/infoXXX \
--with-newlib --with-headers=no \
--disable-bootstrap \
--disable-shared \
--disable-multilib \
--disable-nls \
--disable-mudflap --disable-libmudflap --disable-libssp \
--disable-libgomp \
$armflags
make CFLAGS="-D_GNU_SOURCE -DSTDC_HEADERS -DHAVE_STRSIGNAL -DHAVE_GETRLIMIT \
 -DHAVE_GETRLIMIT -O0 -g0" LDFLAGS="-static" -j$MAKE_THREADS
make DESTDIR="$butch_install_dir" install-gcc

dest="$butch_install_dir""$butch_prefix"
rm -rf "$dest"/infoXXX

[ "$A" = x86_64 ] && mv "$dest"/lib64/* "$dest"/lib/ || true

# rename gcc to rawcc so musl-gcc can call the *right* gcc
mv "$dest"/bin/gcc "$dest"/bin/rawcc
ln -sf "rawcc" "$dest"/bin/gcc

ln -sf rawcc "$dest"/bin/gcc-$VERSION
